﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Model;
using Model.EntityModel;
using DataAccess;
using System.Collections.ObjectModel;

namespace Project
{
    /// <summary>
    /// Lógica de interacción para ViewPsicologistReportContent.xaml
    /// </summary>
    public partial class ViewPsicologistReportContent : UserControl
    {
        PsicologistReportClass rep;

        public ViewPsicologistReportContent()
        {
            InitializeComponent();
        }

        public ViewPsicologistReportContent(PsicologistReportClass report)
        {
            InitializeComponent();
            rep = report;
            UIWindowManager.SetWindowTitle(this, "Brigada De Protección a la Familia - InformePsicologico");
            fillInterface(report);
        }

        public void fillInterface(PsicologistReportClass report)
        {
            tbRecom.Text = report.Recomendations;
            tbFirstContact.Text = report.FirstContact;
            tbBehavior.Text = report.Behavior;
            lbDate.Content = report.Date.ToShortDateString();
            lbTime.Content = report.Time;
            lbChildren.Content = report.Children.ToString();
            lbConvivence.Content = report.Convivence;
            lbTypeOfReason.Content = report.TypeOfReason;
            for (int i = 0; i < report.Interventions.Count; i++)
            {
                listInterventions.Items.Add(report.Interventions[i]);
            }
            for (int i = 0; i < report.Reasons.Count; i++)
            {
                listReasons.Items.Add(report.Reasons[i]);
            }
            for (int i = 0; i < report.Family.Count; i++)
            {
                listAges.Items.Add(report.Family[i].Age);
                listEducation.Items.Add(report.Family[i].Education);
                listNames.Items.Add(report.Family[i].Name);
                listRelations.Items.Add(report.Family[i].Relation);
                listOcupation.Items.Add(report.Family[i].Ocupation);
            }

            lbCase.Content = report.IdComplaint;
            Model.EntityModel.Person person = PersonAndActorDataAccess.GetPersonById(report.IdPerson);
            string actorType = PersonAndActorDataAccess.GetActorRTypeByComplaintIdAndPersonId(report.IdPerson, report.IdComplaint);
            lbActorType.Content = actorType;
            lbCi.Content = person.CiPassport;
            lbName.Content = person.Name;
            lbPaternal.Content = person.PaternalName;
            if (!String.IsNullOrEmpty(person.MaternalName))
                lbMaternal.Content = person.MaternalName;



            /*lbCiPsico.Content = report.CiPsicologist;
            Functionary emp = DataBaseAccess.ReadEmployee(report.CiPsicologist);
            lbPsicologist.Content = emp.Name + emp.PaternalName;
            if (!String.IsNullOrEmpty(emp.MaternalName))
                lbPsicologist.Content += emp.MaternalName;*/
        }

        private void Print_Click(object sender, RoutedEventArgs e)
        {
            var items = new ObservableCollection<UserControl>();
            items.Add(new PrintPsicologistReport(rep));
            items.Add(new PrintPsicologistReportPart2(rep));
            var a = new PrintPreviewDialogV2(items);
            a.MenuItem_Click(null, null);
        }


        public void PrintPreview_Click(object sender, RoutedEventArgs e)
        {
            var items = new ObservableCollection<UserControl>();
            items.Add(new PrintPsicologistReport(rep));
            items.Add(new PrintPsicologistReportPart2(rep));
            var a = new PrintPreviewDialogV2(items);
            a.ShowDialog();
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            UIWindowManager.CleanWindow(this);
        }

        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            DrpDownPrintOptions.IsOpen = true;
        }
    }
}
